package net.udp;

import java.net.InetAddress;
import java.util.Date;

public class UDPTimeClient
{
	public final static int DEFAULT_PORT = 37;
	public final static String DEFAULT_HOST = "time-a.nist.gov";
	public static void main(String[] args)
	{
		InetAddress host;
		int port = DEFAULT_PORT;
		try
		{
			host = InetAddress.getByName(DEFAULT_HOST);
		}
		catch (Exception e)
		{
			return;
		}
		try
		{
			UDPPoke poker = new UDPPoke(host, port);
			byte[] response = poker.poke();
			if(response==null)
			{
				return;
			}else if(response.length == 4)
			{
				return;
			}
			Date time = new Date();
			System.out.println(time);
		}
		catch (Exception e)
		{
		}
	}
}
